package com.richeyward.calculator;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;

public class MainActivity extends Activity {
	LinearLayout llMain;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        createLayout();
        setContentView(llMain);
    }
	private void createLayout() {
		// Declare and assign TextBox
		TextView tv = new TextView(this);
		tv.setText("0");
		
		// Assign Button values
		Button b0 = calcButton.createButton(this,0);
		Button b1 = calcButton.createButton(this,1);
		Button b2 = calcButton.createButton(this,2);
		Button b3 = calcButton.createButton(this,3);
		Button b4 = calcButton.createButton(this,4);
		Button b5 = calcButton.createButton(this,5);
		Button b6 = calcButton.createButton(this,6);
		Button b7 = calcButton.createButton(this,7);
		Button b8 = calcButton.createButton(this,8);
		Button b9 = calcButton.createButton(this,9);
		Button bAdd = calcButton.createButton(this,10);
		Button bSub = calcButton.createButton(this,11);
		Button bMul = calcButton.createButton(this,12);
		Button bDiv = calcButton.createButton(this,13);
		Button bPoint = calcButton.createButton(this,14);
		Button bEqu = calcButton.createButton(this,15);

		// Add TextInfo to LinearLayout
		LinearLayout llTop = new LinearLayout(this);
		llTop.addView(tv);
		
		// Add Buttons to LinearLayouts
		LinearLayout llNumRow1 = new LinearLayout(this);
		llNumRow1.addView(b7);
		llNumRow1.addView(b8);
		llNumRow1.addView(b9);
		llNumRow1.addView(bDiv);
		
		LinearLayout llNumRow2 = new LinearLayout(this);
		llNumRow2.addView(b4);
		llNumRow2.addView(b5);
		llNumRow2.addView(b6);
		llNumRow2.addView(bMul);

		LinearLayout llNumRow3 = new LinearLayout(this);
		llNumRow3.addView(b1);
		llNumRow3.addView(b2);
		llNumRow3.addView(b3);
		llNumRow3.addView(bSub);
		
		LinearLayout llNumRow4 = new LinearLayout(this);
		llNumRow4.addView(bPoint);
		llNumRow4.addView(b0);
		llNumRow4.addView(bEqu);
		llNumRow4.addView(bAdd);

		// Declare LayoutParams
		LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
		params.weight=20;
		llTop.setLayoutParams(params);
		llNumRow1.setLayoutParams(params);
		llNumRow2.setLayoutParams(params);
		llNumRow3.setLayoutParams(params);
		llNumRow4.setLayoutParams(params);
		
		// Add Layouts To Main Layout
		llMain = new LinearLayout(this);
		llMain.setOrientation(LinearLayout.VERTICAL);
		llMain.addView(llTop);
		llMain.addView(llNumRow1);
		llMain.addView(llNumRow2);
		llMain.addView(llNumRow3);
		llMain.addView(llNumRow4);
	}
}
